var chatTable;
function getChatList() {
	if (typeof chatTable !== 'undefined') {
		chatTable.fnPageChange('first');
		return;
	}
	var i = 1;
	chatTable = $("#chatList")
			.DataTable(
					{
						"sAjaxSource" : _path + "/redPacket/queryByPage",
						"fnServerParams" : function(aoData) {
							aoData.push(
									{"name" : "liveId","value" : $("#lid").val()},
									{"name" : "rpType","value" : $("#rpType").val()},
									{"name" : "userNickName","value" : $("#userNickName").val()},
									{ "name": "fromDate", "value": $("#fromDate").val() },
						            { "name": "toDate", "value": $("#toDate").val() }
							);
						},
						"sServerMethod" : "POST",
						"sAjaxDataProp" : "dataList",
						"fnCreatedRow" : function() {
							i++;
						},
						"fnPreDrawCallback" : function() {
							i = 1;
						},
						"aoColumns" : [
								{
									"sTitle" : "序号",
									"sWidth" : "2%",
									"mData" : function() {
										return i;
									}
								},
								{
									"sTitle" : "直播名称",
									"sWidth" : "10%",
									"mData" : function(data) {
										var name=$("#lname").val();
								
										return name;
									}
								},
								{
									"sTitle" : "用户昵称",
									"mData" : "userNickName",
									"sWidth" : "10%"
								},
								{
									"sTitle" : "支付时间",
									"mData" : "createTime",
									"sWidth" : "10%"
								},
								{
									"sTitle" : "金额（元）",
									"mData" : "total",
									"sWidth" : "10%"
								}
								/*,
								{
									"sTitle" : "操作",
									"sWidth" : "10%",
									"mData" : function(data) {
													
										var	status = '&nbsp;<a href="javascript:inquiry('
													+ data.id
													+ ');"  class="btn default btn-xs red"><i class="fa fa-trash-o" title="删除"></i></a>';
								
										return status;
									}
								} */
								]
					});
}





function inquiry(id) {

	layer.confirm('您确定要删除吗？', {
		btn : [ '确定', '取消' ]
	// 按钮
	}, function() {
		layer.closeAll('dialog');
		$.ajax({
			url : _path + "/redPacket/del/" + id,
			type : "get",
			dataType : "json",
			async : false,
			error : function(request) {
				alert("连接错误！");
			},
			success : function(data) {
				  if(data.msg=='成功'){
					  layer.close
					  App.bubble(200, "删除成功");
						getChatList();
				  }else{
					  App.bubble(200, "删除异常");
				  }
			}
		});
	}, function() {

	});
}